﻿/**
 * Description：三定卡片查看 hooks
 * Copyright (c) : 通力凯顿（北京）系统集成有限公司
 * Writer：longb
 * date: 2025.7.15
 */
const { ref, reactive, nextTick } = Vue
import { commonFetch } from '../../../Scripts/ZsJs/commonFetch.js'
const { ElMessage, ElMessageBox } = ElementPlus
export function useThreeCard() {
  const threeCard = reactive({
    threeCardViewDialogVisible: false,
    threeCardDataList: [],
    threeCardResourceList: [],
    threeCardFileList: [],
    threeCardWorkerList: [],
    threeCardCheckerList: []
  })
  //查询三定卡片列表信息
  async function getThreeCardDataList(workflowids, productname) {
    if (workflowids == '') {
      return;
    }
    const formData = new FormData();
    formData.append('workflowids', workflowids);
    formData.append('productname', productname);
    const { tdata, Result } = await commonFetch({
      url: `../../../Ashx/ProductWorkflowDataViewVue3PageHandler.ashx?action=GetThreeFixedCardsData`,
      data: formData
    });
    threeCard.threeCardWorkerList = []
    threeCard.threeCardCheckerList = []
    threeCard.threeCardResourceList = []
    threeCard.threeCardFileList = []
    threeCard.threeCardViewDialogVisible = true;
    threeCard.threeCardDataList = tdata
  }

  //查询三定卡片明细信息
  async function getThreeCardDetailList(id) {
    const formData = new FormData();
    formData.append('id', id);
    const { tdata, Result } = await commonFetch({
      url: `../../../Ashx/ProductWorkflowDataViewVue3PageHandler.ashx?action=GetThreeFixedCardDetail`,
      data: formData
    });
    threeCard.threeCardWorkerList = tdata.value.filter(item => item.threetype === '0')
    threeCard.threeCardCheckerList = tdata.value.filter(item => item.threetype === '1')
    threeCard.threeCardResourceList = tdata.value.filter(item => item.threetype === '2')
    threeCard.threeCardFileList = tdata.value.filter(item => item.threetype === '3')
  }

  return {
    threeCard,
    getThreeCardDataList,
    getThreeCardDetailList
  }

}